package studio.raptor.databus.client;

/**
 * Created on 2017/7/9  <br>
 *
 * @author koalton
 */
class TopicSalt {

  /**
   * 通过事件名称及种类计算对应的Topic的盐值
   * @param eventName 事件名称
   * @param eventKindId 事件种类
   * @return 若返回NUll表示创建失败
   */
  public static String createSalt(String eventName,Integer eventKindId){
    if( null == eventName || null == eventKindId || "".equals(eventName)){
      return null;
    }else{
      int kindIdLength = String.valueOf(eventKindId).length();
      int sum = 0;
      for (int i = 0; i < kindIdLength; i++) {
        sum += Integer.valueOf(String.valueOf(eventKindId).substring(i,i+1)).intValue();
      }
      return eventName.length()+sum+"";
    }
  }

}
